package com.mzw.huaxiarealestatebackend.common.utils;

import java.util.UUID;

public class UIDUtil {
    public static String getUUID(int length) {
        return UUID
                .randomUUID()
                .toString()
                .replace("-", "")
                .substring(0, length);
    }

    public static int getUUNumber(int length) {
        String current = String.valueOf(System.currentTimeMillis());
        String lastDigits = current.substring(current.length() - length);

        try {
            return Integer.parseInt(lastDigits);
        } catch (NumberFormatException e) {
            return 0;
        }
    }
}
